package com.service.impl;

import com.entity.StorageHistory;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.StorageHistoryMapper;
import com.service.StorageHistoryService;
import com.until.ConstantUtil;
import com.vo.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ fileName:StorageHistoryServiceImpl
 * @ description:
 * @ author:dzh
 * @ createTime:2022/5/2 23:48
 * @ version:1.0.0
 */
@Service
public class StorageHistoryServiceImpl implements StorageHistoryService {
    @Resource
    private StorageHistoryMapper mapper;
    @Override
    public PageInfo listByParam(Page<StorageHistory> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());

        return new PageInfo(mapper.listAllByParam(page.getData()));
    }

    @Override
    public int insertOne(StorageHistory storageHistory) {
        storageHistory.setShDate(new Date());
        storageHistory.setShStatus(ConstantUtil.storageStatus.ONE);
        return mapper.insert(storageHistory);
    }
    @Override
    public int insertMore(StorageHistory storageHistory) {
        storageHistory.setShDate(new Date());
        storageHistory.setShStatus(ConstantUtil.storageStatus.MORE);
        return mapper.insert(storageHistory);
    }
}
